package com.authine.cloudpivot.web.api.secondopen.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.authine.cloudpivot.web.api.config.HxConfig;
import com.authine.cloudpivot.web.api.secondopen.dao.*;
import com.authine.cloudpivot.web.api.secondopen.domain.*;
import com.authine.cloudpivot.web.api.secondopen.service.NcInterfaceService;
import com.authine.cloudpivot.web.api.secondopen.utils.HttpRestUtil;
import io.jsonwebtoken.lang.Collections;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.dom4j.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


@Service
public class NcInterfaceServiceImpl implements NcInterfaceService {

    private static final Logger log = LoggerFactory.getLogger(NcInterfaceServiceImpl.class);

    @Autowired
    private HxConfig hxConfig;

    @Autowired
    private Ie6s6GryhzhxxMapper ie6s6GryhzhxxMapper;

    @Autowired
    private Ie6s6GysyhzhxxMapper ie6s6GysyhzhxxMapper;

    @Autowired
    private Ie6s6GyyhzhMapper ie6s6GyyhzhMapper;

    @Autowired
    private Ie6s6JsfsxxMapper ie6s6JsfsxxMapper;

    @Autowired
    private Ie6s6YhcdhpxxMapper ie6s6YhcdhpxxMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private Ie6s6YgyhkxxMapper ie6s6YgyhkxxMapper;


    @Override
    public void syncNcpsnData() throws UnsupportedEncodingException {
        String url = hxConfig.getNcurl();
        url = url + "ncuaptype=ncpsn&sfsc=0&sfsc=0&enablestate=2";
        String result = HttpRestUtil.httpGetUrlWithoutEncrypt(url);
//        result=new String(result.getBytes("ISO-8859-1"),"utf8");
        log.info("------------------------" + JSON.toJSONString(result));
        JSONObject jsonObject = JSONObject.parseObject(result);
        List<Ie6s6Gryhzhxx> ie6s6Gryhzhxxes = new ArrayList<>();
        List<Ie6s6Ygyhkxx> ie6s6Ygyhkxxes = new ArrayList<>();
        if (!StringUtils.isEmpty(result)) {
            String resultCode = jsonObject.getString("resultCode");
            //如果是返回正常
            if("1".equals(resultCode)){
                JSONArray data = jsonObject.getJSONArray("listdata");
                log.info("**列表接口返回:{}", data);
                if (!CollectionUtils.isEmpty(data)) {
                    int size = data.size();
                    for (int i = 0; i < size; i++) {
                        JSONObject object = (JSONObject) data.get(i);
                        String rybm = object.getString("code");
                        String ryxm = object.getString("name");
                        String yhhm = object.getString("accname");
                        String yhkh = object.getString("accnum");
                        String khh = object.getString("khhmc");
                        String khzh = object.getString("khzhmc");
                        //根据人员编码查询用户信息
                        if(StringUtils.isNotBlank(rybm)){
                            List<HOrgUser> hOrgUser=userMapper.selectUserInfoByEmployeeNo(rybm);
                            if(!Collections.isEmpty(hOrgUser)){
                                String userId=hOrgUser.get(0).getId();
                                String id = "[{\"id\":\""+userId+"\",\"type\":3}]";
                                Ie6s6Ygyhkxx ie6s6Ygyhkxx=this.converYgyhkxx(rybm,id,yhhm,yhkh,khh,khzh);
                                ie6s6Ygyhkxxes.add(ie6s6Ygyhkxx);
                            }
                        }


                        Ie6s6Gryhzhxx ie6s6Gryhzhxx=this.converGryhzhxx(rybm,ryxm,yhhm,yhkh,khh,khzh);
                        ie6s6Gryhzhxxes.add(ie6s6Gryhzhxx);
                    }
                }
                //删除所有数据
                int nums=ie6s6YgyhkxxMapper.deleteYgyhkxx();
                log.info("---------------同步删除员工银行卡信息数据{}条",nums);
                //插入数据
                if(!Collections.isEmpty(ie6s6Ygyhkxxes)){
                    int n=ie6s6YgyhkxxMapper.insertYgyhkxx(ie6s6Ygyhkxxes);
                    log.info("----------------同步插入员工银行卡信息数据{}条",n);
                }


                //删除所有数据
                int num=ie6s6GryhzhxxMapper.deleteGryhzhxx();
                log.info("---------------同步删除nc个人银行账户信息数据{}条",num);
                //插入数据
                if(!Collections.isEmpty(ie6s6Gryhzhxxes)){
                    int n=ie6s6GryhzhxxMapper.insertGryhzhxx(ie6s6Gryhzhxxes);
                    log.info("----------------同步插入nc个人银行账户信息数据{}条",n);
                }
            }
        }
    }

    private Ie6s6Ygyhkxx converYgyhkxx(String rybm,String id, String yhhm, String yhkh, String khh, String khzh) {
        Ie6s6Ygyhkxx ie6s6Ygyhkxx = new Ie6s6Ygyhkxx();
        ie6s6Ygyhkxx.setId(rybm+yhkh);
        ie6s6Ygyhkxx.setCreater("");
        ie6s6Ygyhkxx.setCreateddeptid("");
        ie6s6Ygyhkxx.setOwner("");
        ie6s6Ygyhkxx.setOwnerdeptid("");
        ie6s6Ygyhkxx.setCreatedtime(new Date());
        ie6s6Ygyhkxx.setModifier("");
        ie6s6Ygyhkxx.setModifiedtime(new Date());
        ie6s6Ygyhkxx.setSequencestatus("COMPLETED");
        ie6s6Ygyhkxx.setOwnerdeptquerycode("1");
        ie6s6Ygyhkxx.setYg(id);
        ie6s6Ygyhkxx.setKhh(khh);
        ie6s6Ygyhkxx.setKhzh(khzh);
        ie6s6Ygyhkxx.setYhzh(yhkh);
        return ie6s6Ygyhkxx;
    }

    @Override
    public void syncNcsupData() {
        String url = hxConfig.getNcurl();
        url = url + "ncuaptype=ncsupbank";
        String result = HttpRestUtil.httpGetUrlWithoutEncrypt(url);
        log.info("------------------------" + JSON.toJSONString(result));
        JSONObject jsonObject = JSONObject.parseObject(result);
        List<Ie6s6Gysyhzhxx> ie6s6Gysyhzhxxes = new ArrayList<>();
        if (!StringUtils.isEmpty(result)) {
            String resultCode = jsonObject.getString("resultCode");
            //如果是返回正常
            if("1".equals(resultCode)){
                JSONArray data = jsonObject.getJSONArray("listdata");
                log.info("**列表接口返回:{}", data);
                if (!CollectionUtils.isEmpty(data)) {
                    int size = data.size();
                    for (int i = 0; i < size; i++) {
                        JSONObject object = (JSONObject) data.get(i);
                        String gysbm = object.getString("code");
                        String gysmc = object.getString("name");
                        String yhkh = object.getString("accnum");
                        String yhmc = object.getString("accname");
                        String yhfl = object.getString("accclass");
                        String khhfl = object.getString("pk_banktype");
                        String khyh = object.getString("pk_bankdoc");
                        String nsrsbh = object.getString("taxpayerid");
                        Ie6s6Gysyhzhxx ie6s6Gysyhzhxx=this.converGysyhzhxx(gysbm,gysmc,yhkh,yhmc,yhfl,khhfl,khyh,nsrsbh);
                        ie6s6Gysyhzhxxes.add(ie6s6Gysyhzhxx);
                    }
                }
                //删除所有数据
                int num=ie6s6GysyhzhxxMapper.deleteGysyhzhxx();
                log.info("---------------同步删除nc供应商银行账户信息数据{}条",num);
                //插入数据
                if(!Collections.isEmpty(ie6s6Gysyhzhxxes)){
                    int n=0;
                    for (Ie6s6Gysyhzhxx ie6s6Gysyhzhxx : ie6s6Gysyhzhxxes) {
                        if(ie6s6Gysyhzhxx!=null){
                            try {
                                if(ie6s6GysyhzhxxMapper.insertGysyhzhxx(ie6s6Gysyhzhxx)>0){
                                    n++;
                                }
                            }catch (Exception e){
                                continue;
                            }
                        }
                    }
                    log.info("----------------同步插入nc供应商银行账户信息数据{}条",n);
                }
            }
        }
    }

    @Override
    public void syncNcorgaccountData() {
        String url = hxConfig.getNcurl();
        url = url + "ncuaptype=ncorgaccount";
        String result = HttpRestUtil.httpGetUrlWithoutEncrypt(url);
        log.info("------------------------" + JSON.toJSONString(result));
        JSONObject jsonObject = JSONObject.parseObject(result);
        List<Ie6s6Gyyhzh> ie6s6Gyyhzhs = new ArrayList<>();
        if (!StringUtils.isEmpty(result)) {
            String resultCode = jsonObject.getString("resultCode");
            //如果是返回正常
            if("1".equals(resultCode)){
                JSONArray data = jsonObject.getJSONArray("listdata");
                log.info("**列表接口返回:{}", data);
                if (!CollectionUtils.isEmpty(data)) {
                    int size = data.size();
                    for (int i = 0; i < size; i++) {
                        JSONObject object = (JSONObject) data.get(i);
                        String yhfl = object.getString("accclass");
                        String khhfl = object.getString("pk_banktype");
                        String zhlx = object.getString("zhlx");
                        String khyh = object.getString("pk_bankdoc");
                        String yhkh = object.getString("accnum");
                        String yhmc = object.getString("accname");
                        String sszz = object.getString("pk_org");
                        String zzbm = object.getString("pk_cust_code");
                        String zzmc = object.getString("pk_cust");
                        Ie6s6Gyyhzh ie6s6Gyyhzh=this.converGyyhzh(yhfl,khhfl,zhlx,khyh,yhkh,yhmc,sszz,zzbm,zzmc);
                        ie6s6Gyyhzhs.add(ie6s6Gyyhzh);
                    }
                }
                //删除所有数据
                int num=ie6s6GyyhzhMapper.deleteGyyhzh();
                log.info("---------------同步删除nc企业银行账户信息数据{}条",num);
                //插入数据
                if(!Collections.isEmpty(ie6s6Gyyhzhs)){
                    int n=0;
                    for (Ie6s6Gyyhzh ie6s6Gyyhzh : ie6s6Gyyhzhs) {
                        if(ie6s6Gyyhzh!=null){
                            try {
                                if(ie6s6GyyhzhMapper.insertGyyhzh(ie6s6Gyyhzh)>0){
                                    n++;
                                }
                            }catch (Exception e){
                                continue;
                            }
                        }
                    }

                    log.info("----------------同步插入nc企业银行账户信息数据{}条",n);
                }
            }
        }

    }

    @Override
    public void syncNcsettlingData() {
        String url = hxConfig.getNcurl();
        url = url + "ncuaptype=ncsettling";
        String result = HttpRestUtil.httpGetUrlWithoutEncrypt(url);
        log.info("------------------------" + JSON.toJSONString(result));
        JSONObject jsonObject = JSONObject.parseObject(result);
        List<Ie6s6Jsfsxx> ie6s6Jsfsxxs = new ArrayList<>();
        if (!StringUtils.isEmpty(result)) {
            String resultCode = jsonObject.getString("resultCode");
            //如果是返回正常
            if("1".equals(resultCode)){
                JSONArray data = jsonObject.getJSONArray("listdata");
                log.info("**列表接口返回:{}", data);
                if (!CollectionUtils.isEmpty(data)) {
                    int size = data.size();
                    for (int i = 0; i < size; i++) {
                        JSONObject object = (JSONObject) data.get(i);
                        String code = object.getString("code");
                        String name = object.getString("name");
                        Ie6s6Jsfsxx ie6s6Jsfsxx=this.converNcsettling(code,name);
                        ie6s6Jsfsxxs.add(ie6s6Jsfsxx);
                    }
                }
                //插入数据
                if(!Collections.isEmpty(ie6s6Jsfsxxs)){
                    int n=ie6s6JsfsxxMapper.insertJsfsxx(ie6s6Jsfsxxs);
                    log.info("----------------同步结算方式数据{}条",n);
                }
            }
        }

    }

    @Override
    public void syncNcexchangeData() {
        String url = hxConfig.getNcurl();
        url = url + "ncuaptype=ncexchange";
        String result = HttpRestUtil.httpGetUrlWithoutEncrypt(url);
        log.info("------------------------" + JSON.toJSONString(result));
        JSONObject jsonObject = JSONObject.parseObject(result);
        List<Ie6s6Yhcdhpxx> ie6s6Yhcdhpxxes = new ArrayList<>();
        if (!StringUtils.isEmpty(result)) {
            String resultCode = jsonObject.getString("resultCode");
            //如果是返回正常
            if("1".equals(resultCode)){
                JSONArray data = jsonObject.getJSONArray("listdata");
                log.info("**列表接口返回:{}", data);
                if (!CollectionUtils.isEmpty(data)) {
                    int size = data.size();
                    for (int i = 0; i < size; i++) {
                        JSONObject object = (JSONObject) data.get(i);
                        String djlx = object.getString("djlx");
                        String fbmbillno = object.getString("fbmbillno");
                        BigDecimal money = object.getBigDecimal("money");
                        String enddate = object.getString("enddate");
                        String zzbm = object.getString("zzbm");
                        String zzmc = object.getString("zzmc");
                        Ie6s6Yhcdhpxx ie6s6Yhcdhpxx=this.converYhcdhpxx(djlx,fbmbillno,money,enddate,zzbm,zzmc);
                        ie6s6Yhcdhpxxes.add(ie6s6Yhcdhpxx);
                    }
                }
                //删除所有数据
                int num=ie6s6YhcdhpxxMapper.deleteNcexchange();
                log.info("---------------同步删除nc企业银行账户信息数据{}条",num);
                //插入数据
                if(!Collections.isEmpty(ie6s6Yhcdhpxxes)){
                    int n=ie6s6YhcdhpxxMapper.insertNcexchange(ie6s6Yhcdhpxxes);
                    log.info("----------------同步插入nc企业银行账户信息数据{}条",n);
                }
            }
        }
    }

    @Override
    public Sendresult pushNcFkjsDData(Cmppaybill cmppaybill) throws DocumentException {
        String xml=this.converCmppaybill(cmppaybill);
        log.info("----------------xml信息为：{}",xml);
        String ncxmlurl=hxConfig.getNcxmlurl();
        String result=HttpRestUtil.postDataSOAP(ncxmlurl,xml);
//        String result="<?xml version=\"1.0\" encoding='UTF-8'?><ufinterface billtype=\"cmppaybill\" filename=\"cmppaybilld3eaOA.xml\" isexchange=\"Y\" replace=\"Y\" roottag=\"sendresult\" sender=\"OA\" successful=\"Y\">    <sendresult>        <billpk>        </billpk>        <bdocid>17d79b5d4960000000000000000000cmppaybill0</bdocid>        <filename>cmppaybilld3eaOA.xml</filename>        <resultcode>1</resultcode>        <resultdescription>单据  17d79b5d4960000000000000000000cmppaybill0  开始处理...单据  17d79b5d4960000000000000000000cmppaybill0  处理完毕!</resultdescription>        <content>1001A1100000000A3BWA</content>    </sendresult></ufinterface>";
        if (!StringUtils.isEmpty(result)) {
            Document document=DocumentHelper.parseText(result);
            Node resultcode = document.selectSingleNode("//resultcode");
            Node resultdescription = document.selectSingleNode("//resultdescription");
            Node filename = document.selectSingleNode("//filename");
            Node content = document.selectSingleNode("//content");
            Sendresult sendresult=new Sendresult();
            sendresult.setResultcode(resultcode.getText());
            sendresult.setResultdescription(resultdescription.getText());
            sendresult.setFilename(filename.getText());
            sendresult.setContent(content.getText());
            return sendresult;
        }else{
            return null;
        }

    }

    private String converCmppaybill(Cmppaybill cmppaybill) {
        StringBuffer data = new StringBuffer();
        data.append("<?xml version=\"1.0\" encoding='UTF-8'?><ufinterface account=\"develop\" billtype=\"cmppaybill\" businessunitcode=\"\" filename=\"\" groupcode=\"\" isexchange=\"Y\" orgcode=\"\" receiver=\"\" replace=\"\" roottag=\"\" sender=\"OA\"><bill id=\"");
//        data.append();
        data.append("\"><billhead><pk_group>");
        data.append(cmppaybill.getPkGroup());
        data.append("</pk_group><pk_org>");
        data.append(cmppaybill.getPkOrg());
        data.append("</pk_org><trade_type>");
        data.append(cmppaybill.getTradeType());
        data.append("</trade_type><bill_date>");
        data.append(cmppaybill.getBillDate());
        data.append("</bill_date><source_flag>");
        data.append(cmppaybill.getSourceFlag());
        data.append("</source_flag><bill_status>");
        data.append(cmppaybill.getBillStatus());
        data.append("</bill_status><creator>");
        data.append(cmppaybill.getCreator());
        data.append("</creator><creationtime>");
        data.append(cmppaybill.getCreationtime());
        data.append("</creationtime><billmaker>");
        data.append(cmppaybill.getBillmaker());
        data.append("</billmaker><billmaker_date>");
        data.append(cmppaybill.getBillmakerDate());
        data.append("</billmaker_date><primal_money>");
        data.append(cmppaybill.getPrimalMoney());
        data.append("</primal_money><local_money>");
        data.append(cmppaybill.getLocalMoney());
        data.append("</local_money><memo>");
        data.append(cmppaybill.getMemo());
        data.append("</memo><effect_flag>");
        data.append(cmppaybill.getEffectFlag());
        data.append("</effect_flag><payway>");
        data.append(cmppaybill.getPayway());
        data.append("</payway><isnetready>");
        data.append(cmppaybill.getIsnetready());
        data.append("</isnetready><isreded>");
        data.append(cmppaybill.getIsreded());
        data.append("</isreded><group_local>");
        data.append(cmppaybill.getGroupLocal());
        data.append("</group_local><global_local>");
        data.append(cmppaybill.getGlobalLocal());
        data.append("</global_local><group_rate>");
        data.append(cmppaybill.getGroupRate());
        data.append("</group_rate><global_rate>");
        data.append(cmppaybill.getGlobalRate());
        data.append("</global_rate><objecttype>");
        data.append(cmppaybill.getObjecttype());
        if(cmppaybill.getObjecttype()==1){
            data.append("</objecttype><pk_supplier>");
            data.append(cmppaybill.getPkSupplier());
            data.append("</pk_supplier><pk_balatype>");
        }else if(cmppaybill.getObjecttype()==3){
            data.append("</objecttype><pk_busiman>");
            data.append(cmppaybill.getPkBusiman());
            data.append("</pk_busiman><pk_balatype>");
        }

        data.append(cmppaybill.getPkBalatype());
        data.append("</pk_balatype><pk_account>");
        data.append(cmppaybill.getPkAccount());
        data.append("</pk_account><pk_oppaccount>");
        data.append(cmppaybill.getPkOppaccount());
        data.append("</pk_oppaccount><pk_currtype>");
        data.append(cmppaybill.getPkCurrtype());
        data.append("</pk_currtype><local_rate>");
        data.append(cmppaybill.getLocalRate());
        data.append("</local_rate><savedate>");
        data.append(cmppaybill.getSavedate());
        data.append("</savedate><is_cf>");
        data.append(cmppaybill.getIsCf());
        data.append("</is_cf><billclass>");
        data.append(cmppaybill.getBillclass());
        data.append("</billclass><bill_type>");
        data.append(cmppaybill.getBillType());
        data.append("</bill_type><memo>");
        data.append(cmppaybill.getMemo());
        data.append("</memo><items>");
        if(!Collections.isEmpty(cmppaybill.getCmppaybillDeatails())){
            for (CmppaybillDeatail cmppaybillDeatail : cmppaybill.getCmppaybillDeatails()) {
                data.append("<item><accountname>");
                data.append(cmppaybillDeatail.getAccountname());
                data.append("</accountname><bill_date>");
                data.append(cmppaybillDeatail.getBillDate());
                data.append("</bill_date><bill_type>");
                data.append(cmppaybillDeatail.getBillType());
                data.append("</bill_type><billclass>");
                data.append(cmppaybillDeatail.getBillClass());
                data.append("</billclass><billdetail_no>");
                data.append(cmppaybillDeatail.getBilldetailNo());
                data.append("</billdetail_no><creationtime>");
                data.append(cmppaybillDeatail.getCreationtime());
                data.append("</creationtime><creator>");
                data.append(cmppaybillDeatail.getCreator());
                data.append("</creator><direction>");
                data.append(cmppaybillDeatail.getDirection());
                data.append("</direction><djxtflag>");
                data.append(cmppaybillDeatail.getDjxtflag());
                data.append("</djxtflag><global_local_pay>");
                data.append(cmppaybillDeatail.getGlobalLocalPay());
                data.append("</global_local_pay><global_rate>");
                data.append(cmppaybillDeatail.getGlobalRate());
                data.append("</global_rate><group_local_pay>");
                data.append(cmppaybillDeatail.getGroupLocalPay());
                data.append("</group_local_pay><group_rate>");
                data.append(cmppaybillDeatail.getGroupRate());
                data.append("</group_rate><local_rate>");
                data.append(cmppaybillDeatail.getLocalRate());
                data.append("</local_rate><modifiedtime>");
                data.append(cmppaybillDeatail.getModifiedtime());
                data.append("</modifiedtime><objecttype>");
                data.append(cmppaybillDeatail.getObjecttype());
                data.append("</objecttype><pay_local>");
                data.append(cmppaybillDeatail.getPayLocal());
                data.append("</pay_local><pay_primal>");
                data.append(cmppaybillDeatail.getPayPrimal());
                data.append("</pay_primal><paystatus>");
                data.append(cmppaybillDeatail.getPaystatus());
                data.append("</paystatus><pk_account>");
                data.append(cmppaybillDeatail.getPkAccount());
                data.append("</pk_account><pk_balatype>");
                data.append(cmppaybillDeatail.getPkBalatype());
                if(cmppaybillDeatail.getObjecttype()==1){
                    data.append("</pk_balatype><pk_supplier>");
                    data.append(cmppaybillDeatail.getPkSupplier());
                    data.append("</pk_supplier><pk_currtype>");
                }else if(cmppaybillDeatail.getObjecttype()==3){
                    data.append("</pk_balatype><pk_busiman>");
                    data.append(cmppaybillDeatail.getPkBusiman());
                    data.append("</pk_busiman><pk_currtype>");
                }

                data.append(cmppaybillDeatail.getPkCurrtype());
                data.append("</pk_currtype><pk_group>");
                data.append(cmppaybillDeatail.getPkGroup());
                data.append("</pk_group><pk_oppaccount>");
                data.append(cmppaybillDeatail.getPkOppaccount());
                data.append("</pk_oppaccount><pk_org>");
                data.append(cmppaybillDeatail.getPkOrg());
                data.append("</pk_org><rec_flag>");
                data.append(cmppaybillDeatail.getRecFlag());
                data.append("</rec_flag><trade_type>");
                data.append(cmppaybillDeatail.getTradeType());
                data.append("</trade_type><memo>");
                data.append(cmppaybillDeatail.getMemo());
                data.append("</memo><accountopenbank>");
                data.append(cmppaybillDeatail.getAccountopenbank());
                data.append("</accountopenbank><accounttype>");
                data.append(cmppaybillDeatail.getAccounttype());
                data.append("</accounttype></item>");
            }

        }

        data.append("</items><def1>");
        data.append(cmppaybill.getDef1());
        data.append("</def1></billhead></bill></ufinterface>");
        return data.toString();
    }

    private Ie6s6Yhcdhpxx converYhcdhpxx(String djlx, String fbmbillno, BigDecimal money, String enddate, String zzbm, String zzmc) {
        Ie6s6Yhcdhpxx ie6s6Yhcdhpxx = new Ie6s6Yhcdhpxx();
//        String uuid= UUID.randomUUID().toString().replaceAll("-","");
        ie6s6Yhcdhpxx.setId(zzbm+fbmbillno);
        ie6s6Yhcdhpxx.setCreater("");
        ie6s6Yhcdhpxx.setCreatedDeptId("");
        ie6s6Yhcdhpxx.setOwner("");
        ie6s6Yhcdhpxx.setOwnerDeptId("");
        ie6s6Yhcdhpxx.setCreatedTime(new Date());
        ie6s6Yhcdhpxx.setModifier("");
        ie6s6Yhcdhpxx.setModifiedTime(new Date());
        ie6s6Yhcdhpxx.setSequenceStatus("COMPLETED");
        ie6s6Yhcdhpxx.setOwnerDeptQueryCode("1");
        ie6s6Yhcdhpxx.setDjlx(djlx);
        ie6s6Yhcdhpxx.setCdpjh(fbmbillno);
        ie6s6Yhcdhpxx.setDjrq(enddate);
        ie6s6Yhcdhpxx.setPjje(money);
        ie6s6Yhcdhpxx.setZzbm(zzbm);
        ie6s6Yhcdhpxx.setZzmc(zzmc);
        return ie6s6Yhcdhpxx;
    }

    private Ie6s6Jsfsxx converNcsettling(String code, String name) {
        Ie6s6Jsfsxx ie6s6Jsfsxx = new Ie6s6Jsfsxx();
        String uuid= UUID.randomUUID().toString().replaceAll("-","");
        ie6s6Jsfsxx.setId(uuid);
        ie6s6Jsfsxx.setCreater("");
        ie6s6Jsfsxx.setCreatedDeptId("");
        ie6s6Jsfsxx.setOwner("");
        ie6s6Jsfsxx.setOwnerDeptId("");
        ie6s6Jsfsxx.setCreatedTime(new Date());
        ie6s6Jsfsxx.setModifier("");
        ie6s6Jsfsxx.setModifiedTime(new Date());
        ie6s6Jsfsxx.setSequenceStatus("COMPLETED");
        ie6s6Jsfsxx.setOwnerDeptQueryCode("1");
        ie6s6Jsfsxx.setJsfsbm(code);
        ie6s6Jsfsxx.setJsfsmc(name);
        return ie6s6Jsfsxx;
    }

    private Ie6s6Gyyhzh converGyyhzh(String yhfl, String khhfl, String zhlx, String khyh, String yhkh, String yhmc, String sszz, String zzbm, String zzmc) {
        Ie6s6Gyyhzh ie6s6Gyyhzh = new Ie6s6Gyyhzh();
        ie6s6Gyyhzh.setId(zzbm+yhkh);
        ie6s6Gyyhzh.setCreater("");
        ie6s6Gyyhzh.setCreatedDeptId("");
        ie6s6Gyyhzh.setOwner("");
        ie6s6Gyyhzh.setOwnerDeptId("");
        ie6s6Gyyhzh.setCreatedTime(new Date());
        ie6s6Gyyhzh.setModifier("");
        ie6s6Gyyhzh.setModifiedTime(new Date());
        ie6s6Gyyhzh.setSequenceStatus("COMPLETED");
        ie6s6Gyyhzh.setOwnerDeptQueryCode("1");
        ie6s6Gyyhzh.setYhfl(yhfl);
        ie6s6Gyyhzh.setKhhfl(khhfl);
        ie6s6Gyyhzh.setZhlx(zhlx);
        ie6s6Gyyhzh.setKhyh(khyh);
        ie6s6Gyyhzh.setYhkh(yhkh);
        ie6s6Gyyhzh.setYhmc(yhmc);
        ie6s6Gyyhzh.setSszz(sszz);
        ie6s6Gyyhzh.setZzbm(zzbm);
        ie6s6Gyyhzh.setZzmc(zzmc);
        return ie6s6Gyyhzh;
    }

    private Ie6s6Gysyhzhxx converGysyhzhxx(String gysbm, String gysmc, String yhkh, String yhmc, String yhfl, String khhfl, String khyh, String nsrsbh) {
        Ie6s6Gysyhzhxx ie6s6Gysyhzhxx = new Ie6s6Gysyhzhxx();
        ie6s6Gysyhzhxx.setId(gysbm+yhkh);
        ie6s6Gysyhzhxx.setCreater("");
        ie6s6Gysyhzhxx.setCreatedDeptId("");
        ie6s6Gysyhzhxx.setOwner("");
        ie6s6Gysyhzhxx.setOwnerDeptId("");
        ie6s6Gysyhzhxx.setCreatedTime(new Date());
        ie6s6Gysyhzhxx.setModifier("");
        ie6s6Gysyhzhxx.setModifiedTime(new Date());
        ie6s6Gysyhzhxx.setSequenceStatus("COMPLETED");
        ie6s6Gysyhzhxx.setOwnerDeptQueryCode("1");
        ie6s6Gysyhzhxx.setGysbm(gysbm);
        ie6s6Gysyhzhxx.setGysmc(gysmc);
        ie6s6Gysyhzhxx.setYhkh(yhkh);
        ie6s6Gysyhzhxx.setYhmc(yhmc);
        ie6s6Gysyhzhxx.setYhfl(yhfl);
        ie6s6Gysyhzhxx.setKhhfl(khhfl);
        ie6s6Gysyhzhxx.setKhyh(khyh);
        ie6s6Gysyhzhxx.setNsrsbh(nsrsbh);
        return ie6s6Gysyhzhxx;
    }


    public Ie6s6Gryhzhxx converGryhzhxx(String rybm,String ryxm,String yhhm,String yhkh,String khh,String khzh){
        Ie6s6Gryhzhxx ie6s6Gryhzhxx = new Ie6s6Gryhzhxx();
        ie6s6Gryhzhxx.setId(rybm+yhkh);
        ie6s6Gryhzhxx.setCreater("");
        ie6s6Gryhzhxx.setCreatedDeptId("");
        ie6s6Gryhzhxx.setOwner("");
        ie6s6Gryhzhxx.setOwnerDeptId("");
        ie6s6Gryhzhxx.setCreatedTime(new Date());
        ie6s6Gryhzhxx.setModifier("");
        ie6s6Gryhzhxx.setModifiedTime(new Date());
        ie6s6Gryhzhxx.setSequenceStatus("COMPLETED");
        ie6s6Gryhzhxx.setOwnerDeptQueryCode("1");
        ie6s6Gryhzhxx.setRybm(rybm);
        ie6s6Gryhzhxx.setRyxm(ryxm);
        ie6s6Gryhzhxx.setYhhm(yhhm);
        ie6s6Gryhzhxx.setYhkh(yhkh);
        ie6s6Gryhzhxx.setKhh(khh);
        ie6s6Gryhzhxx.setKhzh(khzh);
        return ie6s6Gryhzhxx;
    }
}